#!/usr/bin/python

'''
run: 'ssh-keygen -t rsa'
every thing choose default(just enter)
run 'cp  ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys' on local machine
run 'scp ~/.ssh/id_rsa.pub username@server:.ssh/elwin.pub' on local machine
run 'cat ~/.ssh/elwin.pub >> ~/.ssh/authorized_keys' on server
run 'ssh-add ~/.ssh/id_rsa' on local machine
that is all~~~~

when it's not worked, try:
1.chmod 700 ~/.ssh
2.chmod 600 ~/.ssh/authorized_keys
3.chmod go-wrx ~

'''

import sys
import os

ssh_map = {
		'mine'	: 'elwin@192.168.32.164',	# passwd:
		'185'	: 'kaifa@61.135.210.185',	# passwd: nEW$36&@sT
		'56'	: 'sstech@61.135.210.56',	# passwd: Te&*~2012CH
		'136'	: 'newstech@111.206.69.136',	# passwd: nEW$7&8@s(T)
		'137'	: 'newstech@111.206.69.137',	# passwd: nEW$7&8@s(T)

		'43'	: 'kaifa@61.135.210.43',	# passwd: KaI$36eiTsT

		'2x31'	: 'newstech@111.206.71.31',	# passwd: nEW$36&@sT
		'2x33'	: 'newstech@111.206.71.33',	# passwd: nEW$36&@sT
		'2x34'	: 'newstech@111.206.71.34',	# passwd: nEW$36&@sT

		'bc94'	: 'newstech@61.135.210.94',	# passwd: nEW$36&@sT
		'bc95'	: 'newstech@61.135.210.95',	# passwd: nEW$36&@sT

		'video46' : 'kaifa@111.206.69.46',	# passwd: ZhongSou_jsz@#2005
		'video47' : 'kaifa@111.206.69.47',	# passwd: ZhongSou_jsz@#2005
		'video48' : 'kaifa@111.206.69.48',	# passwd: ZhongSou_jsz@#2005
		'video49' : 'kaifa@111.206.69.49',	# passwd: ZhongSou_jsz@#2005
		'video50' : 'kaifa@111.206.69.50',	# passwd: ZhongSou_jsz@#2005
		'video51' : 'kaifa@111.206.69.51',	# passwd: ZhongSou_jsz@#2005
		'video52' : 'kaifa@111.206.69.52',	# passwd: ZhongSou_jsz@#2005
		'video53' : 'kaifa@111.206.69.53',	# passwd: ZhongSou_jsz@#2005
		'video54' : 'kaifa@111.206.69.54',	# passwd: ZhongSou_jsz@#2005
		'video55' : 'kaifa@111.206.69.55',	# passwd: ZhongSou_jsz@#2005

		'hems-ds86' : 'kaifa@111.206.69.86',	# passwd: RV6))!KAiiZS2
		'hems-ds87' : 'kaifa@111.206.69.87',	# passwd: RV6))!KAiiZS2
		'hems-ds88' : 'kaifa@111.206.69.88',	# passwd: RV6))!KAiiZS2
		'hems-ds89' : 'kaifa@111.206.69.89',	# passwd: RV6))!KAiiZS2
		'hems-ds90' : 'kaifa@111.206.69.90',	# passwd: RV6))!KAiiZS2
		'hems-ds91' : 'kaifa@111.206.69.91',	# passwd: RV6))!KAiiZS2
		'hems-ds99' : 'kaifa@111.206.69.99',	# passwd: RV6))!KAiiZS2
		'hems-ds100' : 'kaifa@111.206.69.100',	# passwd: RV6))!KAiiZS2
		'hems-ds95' : 'kaifa@111.206.69.95',	# passwd: RV6))!KAiiZS2
		'hems-ds112' : 'kaifa@111.206.69.112',	# passwd: RV6))!KAiiZS2
		}

if len(sys.argv) != 2:
	print 'Usage: gssh server_name'
	exit(0)

if sys.argv[1] == 'init':
	complete_argv = ''
	for i in ssh_map.keys():
		complete_argv += i
		complete_argv += ' '
	print 'complete -W "' + complete_argv + '" ' + sys.argv[0].split("/")[-1]
	exit(0)

if ssh_map.has_key(sys.argv[1]):
	os.system('ssh ' + ssh_map[sys.argv[1]]);
else:
	print 'There are several suitable:'
	for i in ssh_map.keys():
		print i + '\t' + ssh_map[i]
